//
//  EFTagButton.m
//  ESPMobileView
//
//  Created by 虎 谢 on 2017/12/11.
//  Copyright © 2017年 Pansoft. All rights reserved.
//

#import "EFTagButton.h"
#import "Masonry.h"


@implementation EFTagButton

+(EFTagButton *)efBUttonWithType:(UIButtonType)type {
    return [EFTagButton buttonWithType:type];
}

#pragma mark -IBadgeView
-(void)badgePlusOne {
    self.tagView.badgeValue = [NSString stringWithFormat:@"%ld",[self.tagView.badgeValue integerValue]+1];
}

-(void)badgeMinusOne {
    self.tagView.badgeValue = [NSString stringWithFormat:@"%ld",[self.tagView.badgeValue integerValue]-1];
}

-(void)badgeChange:(NSInteger)count {
    if (count<=0) {
        self.tagView.badgeValue = @"0";
    }else {
        self.tagView.badgeValue = [NSString stringWithFormat:@"%ld",count];
    }
}

#pragma mark - lazyload
- (TagView *)tagView{
    if (!_tagView) {
        _tagView = [[TagView alloc]init];
        [self addSubview:_tagView];
        [_tagView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.equalTo(self).offset(2);
            make.top.equalTo(self).offset(-2);
            make.size.mas_equalTo(CGSizeMake(21, 21));
        }];
    }
    return _tagView;
}

@end
